home *** CD-ROM | disk | FTP | other *** search
- /*
- ** File: ShowHideMenubar.c
- **
- ** Written by: Bill Hayden
- ** Nikol Software
- **
- ** Copyright © 1995 Nikol Software
- ** All rights reserved.
- **
- **
- ** Based on code by:
- ** David Hayward, Developer Technical Support
- ** AppleLink: DEVSUPPORT
- */
-
-
- #include <QuickDraw.h>
- #include <LowMem.h>
-
- #include "ShowHideMenubar.h"
-
-
-
- /*****************************************************************************/
-
-
-
- short gOldBarHgt = 20;
- short gMBarState = SHOW;
- RgnHandle mBarRgn;
-
-
- static void GetMBarRgn ( RgnHandle mBarRgn ) ;
-
-
-
- /*****************************************************************************/
-
-
-
- // changes the menubar state (vis) to either SHOW or HIDE, with obvious results
-
- void SetMBarState (char vis)
- {
- static short first = true;
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- if (first) /* if its the 1st time called */
- {
- gOldBarHgt = GetMBarHeight(); /* remember the bar height */
- first = false;
- }
-
- if (vis == gMBarState) /* return if nothing would change */
- return;
-
- if (!vis) /* if HIDE */
- {
- WindowRef wpFirst = LMGetWindowList();
-
- LMSetMBarHeight(0); /* make the Menu Bar's height zero */
-
- mBarRgn = NewRgn();
- GetMBarRgn(mBarRgn); /* make a region for the mbar */
- UnionRgn(GrayRgn,mBarRgn,GrayRgn); /* tell the desktop it covers the menu bar */
-
- PaintBehind(wpFirst, mBarRgn); /* redraw windows behind front */
- CalcVisBehind(wpFirst, mBarRgn); /* redraw windows behind front */
- }
- else /* if SHOW */
- {
- LMSetMBarHeight(gOldBarHgt); /* make the menu bar's height normal */
-
- DiffRgn(GrayRgn, mBarRgn, GrayRgn); /* remove the menu bar from the desktop */
- DisposeRgn(mBarRgn); /* dispose to the bar region */
-
- DrawMenuBar(); /* redraw the menu bar */
- }
- gMBarState = !gMBarState; /* toggle the state */
- }
-
-
-
- //an accessor to allow others to read private gMBarState global
-
- char GetMBarState (void)
- {
- return gMBarState;
- }
-
-
-
-
- // uses globals to calculate the region for the MenuBar
- // the RgnHandle mBarRgn must be allocated with NewRgn() before calling
-
- static void GetMBarRgn (RgnHandle mBarRgn)
- {
- Rect mBarRect;
-
- mBarRect = qd.screenBits.bounds; /* create a rect for the mbar */
- mBarRect.bottom = mBarRect.top + gOldBarHgt;
- RectRgn(mBarRgn, &mBarRect); /* make a region for the mbar */
- }
-
-
-